package inits

import (
	"api/basic/global"
	__ "api/basic/proto"
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
)

func ServiceRegister() {

	consul := ConsulInit("14.103.233.122:8500")

	config := GrpcConf{
		Name:    "take_out",
		Tags:    []string{"TakeOut"},
		Port:    50051,
		Address: "127.0.0.1:50051",
	}

	err := consul.RegisterService(config)
	if err != nil {
		return
	}

	flag.Parse()
	// Set up a connection to the server.
	conn, err := grpc.NewClient("127.0.0.1:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}

	global.TakeOutClient = __.NewTakeOutClient(conn)

}
